package com.babble.user.feign;

import com.babble.user.dto.UserOrToUserDTO;
import com.babble.user.entity.UserInfo;
import com.babble.user.entity.UserOauth;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(
	value = CommonConstant.BABBLE_USER_NAME
)
public interface IUserClient {
	String API_PREFIX = "/babble/user";

	/**
	 * 获取用户信息
	 *
	 * @param userId 用户id
	 * @return
	 */
	@GetMapping(API_PREFIX + "/user-info-by-id")
	R<UserInfo> userInfo(@RequestParam("userId") String userId);

	/**
	 * 评论模块获取评论人和被评论人的用户名和头像
	 *
	 * @param userId   评论人id
	 * @param toUserId 被评论人id
	 * @return
	 */
	@GetMapping(API_PREFIX + "/user-or-to-user-by-id")
	R<UserOrToUserDTO> userInfoOrToUserinfo(@RequestParam("userId") String userId, @RequestParam("toUserId") String toUserId);

	/**
	 * 获取用户信息
	 *
	 * @param username 用户名/邮箱
	 * @param password 密码
	 * @return UserInfo
	 */
	@GetMapping(API_PREFIX + "/user-info")
	R<UserInfo> userInfo(@RequestParam("username") String username, @RequestParam("password") String password);

	/**
	 * 获取第三方平台信息
	 *
	 * @param userOauth 第三方授权用户信息
	 * @return UserInfo
	 */
	@PostMapping(API_PREFIX + "/user-auth-info")
	R<UserInfo> userAuthInfo(@RequestBody UserOauth userOauth);
}
